/**
 * <strong>Title : ReportServiceImpl.java<br>
 * </strong> <strong>Package : cn.b.sky.mes.mm.service.impl<br>
 * </strong> <strong>Description : </strong>@类注释说明写在此处@<br>
 * <strong>Create on : 2016年3月7日 上午10:12:29<br>
 * </strong>
 * <p>
 * @author dapeng.li<br>
 * @version <strong>v1.0.0</strong><br>
 * <br>
 *          <strong>修改历史:</strong><br>
 *          修改人 | 修改日期 | 修改描述<br>
 *          -------------------------------------------<br>
 * <br>
 * <br>
 */
package cn.b.sky.mes.mm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import cn.b.sky.mes.mm.dao.RequirementTriggerModeDao;
import cn.b.sky.mes.mm.model.RequirementTriggerMode;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import cn.b.sky.mes.mm.model.condition.RequirementTriggerModeCondition;
import cn.b.sky.mes.mm.service.RequirementTriggerModeService;
import cn.b.sky.common.utils.DatabaseUtils;


@Service("requirementTriggerModeService")
public class RequirementTriggerModeServiceImpl implements RequirementTriggerModeService {
  
  private static final Logger LOG = LoggerFactory.getLogger(RequirementTriggerModeServiceImpl.class);
  
  @Resource
  RequirementTriggerModeDao requirementTriggerModeDao;

  @Override
  public List<RequirementTriggerMode> requirementTriggerModeListByCondition(RequirementTriggerModeCondition condition) {
    if (null==condition) {
      return null;
    }    
    return requirementTriggerModeDao.RequirementTriggerModeListByCondition(condition);
  }

  @Override
  public int requirementTriggerModeCountByCondition(RequirementTriggerModeCondition condition) {
    if (null==condition) {
      return 0;
    } 
    return requirementTriggerModeDao.RequirementTriggerModeCountByCondition(condition);
  }

  @Override
  public void insertRequirementTriggerMode(RequirementTriggerMode requirementTriggerMode) {
    if (null!=requirementTriggerMode) {
      requirementTriggerModeDao.insertRequirementTriggerMode(requirementTriggerMode);
    }    
  }

  @Override
  public void updateRequirementTriggerMode(RequirementTriggerMode requirementTriggerMode) {
    if (null!=requirementTriggerMode) {
      requirementTriggerModeDao.updateRequirementTriggerMode(requirementTriggerMode);
    } 
  } 

  @Override
  public RequirementTriggerMode getRequirementTriggerMode(String siteCode, String RequirementTriggerModeCode) {
    if (!StringUtils.isBlank(siteCode) && !StringUtils.isBlank(RequirementTriggerModeCode)) {
      return requirementTriggerModeDao.getRequirementTriggerMode(siteCode, RequirementTriggerModeCode);
    }
    return null;
  }

  @Override
  public String deteleRequirementTriggerMode(String siteCode, String RequirementTriggerModeCode) {
    String message = null;    
    try {
      requirementTriggerModeDao.deteleRequirementTriggerMode(siteCode, RequirementTriggerModeCode);
    } catch (Exception e) {
      LOG.error("{}", e);
      if ((DatabaseUtils.isConstraintsError(e.getMessage()))) {
        message="dataBaseOperationPkFail.M";
      }
    }
    return message;
  }

  @Override
  public List<RequirementTriggerMode> selectRequirementTriggerModeByLockFlag(String siteCode, Integer lockFlag) {
    if (!StringUtils.isBlank(siteCode) && lockFlag!=null) {
      return requirementTriggerModeDao.selectRequirementTriggerModeByLockFlag(siteCode, lockFlag);
    }
    return null;
  }
  

}
